unit SifrantFrm;

interface

uses
  Windows, Classes,
  Controls, StdCtrls, ExtCtrls, ActnList, StdActns, Graphics,
  DB, DBClient, alBaseDataSet, MConnect,
  Forms, DBBaseFrm,
  PoslovanjeSrv_TLB, GlobalSettings,
  cxClasses, cxControls, cxGraphics, cxContainer, cxStyles, cxEditRepositoryItems,
  cxCustomData, cxData, cxFilter,
  cxEdit, cxDBEdit, cxTextEdit, cxDBData,
  cxGrid, cxGridLevel, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
  cxGridBandedTableView, cxGridDBBandedTableView, cxDBEditRepository,
  cxFilterControlDialog, cxFilterControlStrs, cxCurrencyEdit, cxMaskEdit, Menus, ImgList,
  cxDataStorage, kdbstruc, kdbinfo, cxLookAndFeels, cxLookAndFeelPainters,
  dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter;

type
  TfrmSifrant = class(TfrmDBBase)
    pnlClient: TPanel;
    lblNaziv: TLabel;
    pnlTop: TPanel;
    grdMain: TcxGrid;
    grdlvlMain: TcxGridLevel;
    grdtvMain: TcxGridDBBandedTableView;
    grdtvMainID: TcxGridDBBandedColumn;
    grdtvMainNaziv: TcxGridDBBandedColumn;
    edtNaziv: TcxDBMaskEdit;
    rpstMainNaziv: TcxEditRepositoryMaskItem;
    grdtvMainRazredID: TcxGridDBBandedColumn;
    grdtvMainRefID: TcxGridDBBandedColumn;
    procedure OnFilterControlDialogShow(Sender: TObject);
    procedure OnEnter(Sender: TObject);
    procedure OnExit(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure Loaded; override;
    procedure SetDefaultControl; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

var
  frmSifrant: TfrmSifrant;

implementation

uses
  MainFrm;

{$R *.dfm}

{ TfrmSifrant }

constructor TfrmSifrant.Create(AOwner: TComponent);
begin
  inherited;
  with grdtvMain do
  begin
    DataController.Options :=
      DataController.Options + [dcoAssignGroupingValues, dcoAnsiSort];
    OptionsBehavior.IncSearch := True;
    OptionsCustomize.BandMoving := False;
    OptionsCustomize.ColumnFiltering := False;
    OptionsCustomize.ColumnVertSizing := False;
    OptionsCustomize.ColumnMoving := False;
    OptionsData.CancelOnExit := False;
    OptionsData.Deleting := False;
    OptionsData.Editing := False;
    OptionsData.Inserting := False;
    OptionsSelection.CellSelect := False;
    OptionsView.CellEndEllipsis := True;
    OptionsView.ColumnAutoWidth := True;
    OptionsView.GroupByBox := False;
    OptionsView.Indicator := True;
    OptionsView.BandHeaders := False;
    OptionsView.HeaderAutoHeight := True;
    //OptionsView.GroupRowStyle := grsOffice11;
  end;
end;

procedure TfrmSifrant.Loaded;
var
  i: Integer;
begin
  inherited;
  with grdtvMain do
  begin
    grdtvMainID.Visible := False;
    grdtvMainID.Options.Filtering := False;
    grdtvMainRazredID.Visible := False;
    grdtvMainRazredID.Options.Filtering := False;
    grdtvMainRefID.Visible := False;
    grdtvMainRefID.Options.Filtering := False;
    for i := 0 to ColumnCount - 1 do
    begin
      Columns[i].Position.BandIndex := 0;
      Columns[i].Position.RowIndex := 0;
      Columns[i].Position.ColIndex := i;
    end;
  end;
end;

procedure TfrmSifrant.OnEnter(Sender: TObject);
begin
  if Sender is TcxGrid then
    TcxGrid(Sender).RootLevelOptions.DetailFrameColor := ActiveControlColor;
end;

procedure TfrmSifrant.OnExit(Sender: TObject);
begin
  if Sender is TcxGrid then
    TcxGrid(Sender).RootLevelOptions.DetailFrameColor := InactiveControlColor;
end;

procedure TfrmSifrant.OnFilterControlDialogShow(Sender: TObject);
begin
  inherited;
  LocalizeFilter(Sender);
end;

procedure TfrmSifrant.SetDefaultControl;
begin
  inherited;
  if DataSource = dtsrcMain then
    ActiveControl := edtNaziv;
end;

end.

